package com.thiswhyme.easyexcel.controller;

import com.thiswhyme.easyexcel.service.ExcelService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * @author: thiswhyme
 * @date: 2021/9/15
 */
@RestController
@RequestMapping("/excel/web")
public class ExcelController {

    private final ExcelService excelService;

    public ExcelController(ExcelService excelService) {
        this.excelService = excelService;
    }

    @PostMapping("/importAndExport")
    public void importAndExport(@RequestParam MultipartFile file, HttpServletResponse response) {
        excelService.importAndExport(file, response);
    }
}
